package com.evaluation_system.mapper;

import com.evaluation_system.pojo.DTO.CheckerPageQueryDTO;
import com.evaluation_system.pojo.entity.Checker;
import com.evaluation_system.pojo.entity.Uploader;
import com.evaluation_system.pojo.entity.saveFileInfo;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface CheckerMapper {
    @Select("SELECT * FROM file "+
            "ORDER BY id " +
            "LIMIT #{size} OFFSET #{page};")
    List<saveFileInfo> getFileForChecker(@Param("size") int size, @Param("page") int page);
    @Select("SELECT * FROM file where file_name=#{filename}")
    List<saveFileInfo> getOneFileForChecker(String filename);

    @Select("SELECT * FROM checker WHERE id = #{checkerId}")
    Integer checkerIsTable(Integer checkerId);

    @Update("UPDATE file SET is_checked = #{checked} WHERE id = #{fileId}")
    void updateChecker(@Param("checked") Integer checked,@Param("fileId") Integer fileId);


    Page<Checker> pageQuery(CheckerPageQueryDTO checkerPageQueryDTO);

    @Insert("insert into checker (username,password,role) values (#{username},#{password},#{role})")
    void add(Checker checker);

    void update(Checker checker);

    @Delete("delete from checker where id=#{id}")
    void deleteById(Integer id);
}
